package 力扣;

/**
 * @author yyq
 * @create 2022-06-14 15:56
 */
public class leetcode509 {
    public int fib(int n) {
        int a=0;
        int b=1;
        int fn=0;
        if(n==0){
            return 0;
        }
        if(n==1){
            return 1;
        }
        for (int i=2;i<=n;i++){
            fn = a + b;
            a=b;
            b=fn;
        }
        return fn;
    }

}
